// components/navigateBar/navigateBar.js
let event = require('../../libs/eventbus')
import {
    pageInfo
} from "../../utils/pageInfo"
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        title: {
            type: String,
            value: '首页'
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        //导航栏高度
        navHeight: getApp().globalData.navHeight,
        // 状态栏
        statusBarHeight: getApp().globalData.statusBarHeight,
        //胶囊顶部距离顶部的距离
        menuTop: getApp().globalData.menuTop,
        // 胶囊高度
        menuHeight: getApp().globalData.menuHeight,
        pageTitle: "首页",
        navBack: false,
        opacity:0
    },
    attached() {
        console.log('attached')
        let that = this
        event.sub('opcacity', that, function (opacity) {
            console.log(opacity)
          that.setData({
            opacity: opacity
          })
        })
    },
    pageLifetimes: {
        show() {
            const page = getCurrentPages()
            this.setData({
                pageTitle: pageInfo[page[page.length - 1].route],
                navBack: page.length > 1 ? true : false,
            })
        },
    },
    /**
     * 组件的方法列表
     */
    methods: {
        onBack() {
            wx.navigateBack({
                delta: 1
            });
        }
    }
})